<template>
  <div>
    <el-card>
      <div class="up_container">
        <div class="logo">
          <img
            src="https://tse3-mm.cn.bing.net/th/id/OIP-C.wZUUmbT4tf1jXYF6CMxjgwHaHa?w=195&h=196&c=7&r=0&o=7&dpr=1.3&pid=1.7&rm=3" />
          <span>长江二桥</span>
        </div>
        <div class="category">
          <el-menu class="el-menu-demo" mode="horizontal" default-active="" @select="store.selectCategory"
            style="border-bottom: none">
            <el-menu-item index="" @click="store.backHome">首页</el-menu-item>
            <el-menu-item :index="String(item.category_id)" v-for="item in store.categoryData" :key="item.category_id"
              @click="router.push('/')">
              {{ item.category_name }}
            </el-menu-item>
          </el-menu>
        </div>
      </div>
    </el-card>

    <el-card style="height: 600px; margin-top: 10px">
      <div class="down_container">
        <el-card>
          <div class="tag">
            <el-menu class="el-menu-demo" mode="vertical" @select="store.selectTag" style="border-right: none">
              <el-menu-item :index="String(item.tag_id)" v-for="item in store.tagData" :key="item.tag_id"
                @click="router.push('/')" style="height: auto;">
                {{ item.tag_name }}
              </el-menu-item>
            </el-menu>
          </div>
        </el-card>

        <el-card>
          <router-view></router-view>
        </el-card>
      </div>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import useStore from '../store.ts'
import { useRouter } from 'vue-router'

const store = useStore()
const router = useRouter()

onMounted(() => {
  store.getCategoryData()
  store.getTagData()
})

</script>

<style>
.up_container {
  width: 100%;
  height: 60px;
  display: flex;
  justify-content: space-between;
  padding: 5px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);

  .logo {
    height: 100%;
    width: 200px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    transition: all 0.3s ease;

    &:hover {
      transform: translateX(5px);
    }

    img {
      height: 40px;
      width: 40px;
      border-radius: 50%;
      object-fit: cover;
      border: 2px solid #fff;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    }

    span {
      font-size: 22px;
      font-weight: bold;
      color: #409eff;
      text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    }
  }

  .category {
    height: 100%;
    width: 600px;

    .el-menu-demo {
      display: flex;
      justify-content: space-evenly;
      align-items: center;
      background-color: transparent;

      .el-menu-item {
        font-weight: 500;
        color: #606266;
        transition: all 0.3s;
        border-radius: 4px;
        padding: 0 15px;
        /* 增加左右内边距 */
        height: 36px;
        /* 固定高度 */
        line-height: 36px;
        /* 确保文字垂直居中 */

        &:hover {
          color: #409eff;
          background-color: transparent;
          transform: translateY(-2px);
          border-bottom: 2px solid #409eff;
          /* 改为下划线效果 */
        }

        &.is-active {
          color: #409eff;
          background-color: transparent;
          /* 移除背景色 */
          border-bottom: 2px solid #409eff;
          /* 改为下划线效果 */
          transform: none;
        }
      }
    }
  }
}

.down_container {
  width: 100%;
  height: 570px;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  gap: 15px;

  .el-card {
    border-radius: 8px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    transition: all 0.3s;

    &:hover {
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    }
  }

  .tag {
    height: 500px;
    width: 80px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    border-radius: 10px;

    .el-menu-demo {
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      align-items: center;
      height: 100%;
      padding: 15px 0;
      background-color: transparent;

      .el-menu-item {
        writing-mode: vertical-rl;
        text-orientation: upright;
        letter-spacing: 0.1em;
        font-size: 16px;
        font-weight: 500;
        height: auto;
        margin: 8px 0;
        padding: 15px 0;
        color: #606266;
        transition: all 0.3s;
        border-radius: 4px;

        &:hover {
          color: #409eff;
          background-color: rgba(64, 158, 255, 0.1);
          transform: scale(1.05);
        }

        &.is-active {
          color: #fff;
          background-color: #409eff;
          box-shadow: 0 2px 6px rgba(64, 158, 255, 0.5);
        }
      }
    }
  }

  >.el-card:last-child {
    flex: 1;
    overflow: auto;
  }
}
</style>
